var tx_font_awesome_icons = [
    "glass",
    "music",
    "search",
    "envelope-o",
    "heart",
    "star",
    "star-o",
    "user",
    "film",
    "th-large",
    "th",
    "th-list",
    "check",
    "times",
    "search-plus",
    "search-minus",
    "power-off",
    "signal",
    "cog",
    "trash-o",
    "home",
    "file-o",
    "clock-o",
    "road",
    "download",
    "arrow-circle-o-down",
    "arrow-circle-o-up",
    "inbox",
    "play-circle-o",
    "repeat",
    "refresh",
    "list-alt",
    "lock",
    "flag",
    "headphones",
    "volume-off",
    "volume-down",
    "volume-up",
    "qrcode",
    "barcode",
    "tag",
    "tags",
    "book",
    "bookmark",
    "print",
    "camera",
    "font",
    "bold",
    "italic",
    "text-height",
    "text-width",
    "align-left",
    "align-center",
    "align-right",
    "align-justify",
    "list",
    "outdent",
    "indent",
    "video-camera",
    "picture-o",
    "pencil",
    "map-marker",
    "adjust",
    "tint",
    "pencil-square-o",
    "share-square-o",
    "check-square-o",
    "arrows",
    "step-backward",
    "fast-backward",
    "backward",
    "play",
    "pause",
    "stop",
    "forward",
    "fast-forward",
    "step-forward",
    "eject",
    "chevron-left",
    "chevron-right",
    "plus-circle",
    "minus-circle",
    "times-circle",
    "check-circle",
    "question-circle",
    "info-circle",
    "crosshairs",
    "times-circle-o",
    "check-circle-o",
    "ban",
    "arrow-left",
    "arrow-right",
    "arrow-up",
    "arrow-down",
    "share",
    "expand",
    "compress",
    "plus",
    "minus",
    "asterisk",
    "exclamation-circle",
    "gift",
    "leaf",
    "fire",
    "eye",
    "eye-slash",
    "exclamation-triangle",
    "plane",
    "calendar",
    "random",
    "comment",
    "magnet",
    "chevron-up",
    "chevron-down",
    "retweet",
    "shopping-cart",
    "folder",
    "folder-open",
    "arrows-v",
    "arrows-h",
    "bar-chart",
    "twitter-square",
    "facebook-square",
    "camera-retro",
    "key",
    "cogs",
    "comments",
    "thumbs-o-up",
    "thumbs-o-down",
    "star-half",
    "heart-o",
    "sign-out",
    "linkedin-square",
    "thumb-tack",
    "external-link",
    "sign-in",
    "trophy",
    "github-square",
    "upload",
    "lemon-o",
    "phone",
    "square-o",
    "bookmark-o",
    "phone-square",
    "twitter",
    "facebook",
    "github",
    "unlock",
    "credit-card",
    "rss",
    "hdd-o",
    "bullhorn",
    "bell",
    "certificate",
    "hand-o-right",
    "hand-o-left",
    "hand-o-up",
    "hand-o-down",
    "arrow-circle-left",
    "arrow-circle-right",
    "arrow-circle-up",
    "arrow-circle-down",
    "globe",
    "wrench",
    "tasks",
    "filter",
    "briefcase",
    "arrows-alt",
    "users",
    "link",
    "cloud",
    "flask",
    "scissors",
    "files-o",
    "paperclip",
    "floppy-o",
    "square",
    "bars",
    "list-ul",
    "list-ol",
    "strikethrough",
    "underline",
    "table",
    "magic",
    "truck",
    "pinterest",
    "pinterest-square",
    "google-plus-square",
    "google-plus",
    "money",
    "caret-down",
    "caret-up",
    "caret-left",
    "caret-right",
    "columns",
    "sort",
    "sort-desc",
    "sort-asc",
    "envelope",
    "linkedin",
    "undo",
    "gavel",
    "tachometer",
    "comment-o",
    "comments-o",
    "bolt",
    "sitemap",
    "umbrella",
    "clipboard",
    "lightbulb-o",
    "exchange",
    "cloud-download",
    "cloud-upload",
    "user-md",
    "stethoscope",
    "suitcase",
    "bell-o",
    "coffee",
    "cutlery",
    "file-text-o",
    "building-o",
    "hospital-o",
    "ambulance",
    "medkit",
    "fighter-jet",
    "beer",
    "h-square",
    "plus-square",
    "angle-double-left",
    "angle-double-right",
    "angle-double-up",
    "angle-double-down",
    "angle-left",
    "angle-right",
    "angle-up",
    "angle-down",
    "desktop",
    "laptop",
    "tablet",
    "mobile",
    "circle-o",
    "quote-left",
    "quote-right",
    "spinner",
    "circle",
    "reply",
    "github-alt",
    "folder-o",
    "folder-open-o",
    "smile-o",
    "frown-o",
    "meh-o",
    "gamepad",
    "keyboard-o",
    "flag-o",
    "flag-checkered",
    "terminal",
    "code",
    "reply-all",
    "star-half-o",
    "location-arrow",
    "crop",
    "code-fork",
    "chain-broken",
    "question",
    "info",
    "exclamation",
    "superscript",
    "subscript",
    "eraser",
    "puzzle-piece",
    "microphone",
    "microphone-slash",
    "shield",
    "calendar-o",
    "fire-extinguisher",
    "rocket",
    "maxcdn",
    "chevron-circle-left",
    "chevron-circle-right",
    "chevron-circle-up",
    "chevron-circle-down",
    "html5",
    "css3",
    "anchor",
    "unlock-alt",
    "bullseye",
    "ellipsis-h",
    "ellipsis-v",
    "rss-square",
    "play-circle",
    "ticket",
    "minus-square",
    "minus-square-o",
    "level-up",
    "level-down",
    "check-square",
    "pencil-square",
    "external-link-square",
    "share-square",
    "compass",
    "caret-square-o-down",
    "caret-square-o-up",
    "caret-square-o-right",
    "eur",
    "gbp",
    "usd",
    "inr",
    "jpy",
    "rub",
    "krw",
    "btc",
    "file",
    "file-text",
    "sort-alpha-asc",
    "sort-alpha-desc",
    "sort-amount-asc",
    "sort-amount-desc",
    "sort-numeric-asc",
    "sort-numeric-desc",
    "thumbs-up",
    "thumbs-down",
    "youtube-square",
    "youtube",
    "xing",
    "xing-square",
    "youtube-play",
    "dropbox",
    "stack-overflow",
    "instagram",
    "flickr",
    "adn",
    "bitbucket",
    "bitbucket-square",
    "tumblr",
    "tumblr-square",
    "long-arrow-down",
    "long-arrow-up",
    "long-arrow-left",
    "long-arrow-right",
    "apple",
    "windows",
    "android",
    "linux",
    "dribbble",
    "skype",
    "foursquare",
    "trello",
    "female",
    "male",
    "gratipay",
    "sun-o",
    "moon-o",
    "archive",
    "bug",
    "vk",
    "weibo",
    "renren",
    "pagelines",
    "stack-exchange",
    "arrow-circle-o-right",
    "arrow-circle-o-left",
    "caret-square-o-left",
    "dot-circle-o",
    "wheelchair",
    "vimeo-square",
    "try",
    "plus-square-o",
    "space-shuttle",
    "slack",
    "envelope-square",
    "wordpress",
    "openid",
    "university",
    "graduation-cap",
    "yahoo",
    "google",
    "reddit",
    "reddit-square",
    "stumbleupon-circle",
    "stumbleupon",
    "delicious",
    "digg",
    "pied-piper-pp",
    "pied-piper-alt",
    "drupal",
    "joomla",
    "language",
    "fax",
    "building",
    "child",
    "paw",
    "spoon",
    "cube",
    "cubes",
    "behance",
    "behance-square",
    "steam",
    "steam-square",
    "recycle",
    "car",
    "taxi",
    "tree",
    "spotify",
    "deviantart",
    "soundcloud",
    "database",
    "file-pdf-o",
    "file-word-o",
    "file-excel-o",
    "file-powerpoint-o",
    "file-image-o",
    "file-archive-o",
    "file-audio-o",
    "file-video-o",
    "file-code-o",
    "vine",
    "codepen",
    "jsfiddle",
    "life-ring",
    "circle-o-notch",
    "rebel",
    "empire",
    "git-square",
    "git",
    "hacker-news",
    "tencent-weibo",
    "qq",
    "weixin",
    "paper-plane",
    "paper-plane-o",
    "history",
    "circle-thin",
    "header",
    "paragraph",
    "sliders",
    "share-alt",
    "share-alt-square",
    "bomb",
    "futbol-o",
    "tty",
    "binoculars",
    "plug",
    "slideshare",
    "twitch",
    "yelp",
    "newspaper-o",
    "wifi",
    "calculator",
    "paypal",
    "google-wallet",
    "cc-visa",
    "cc-mastercard",
    "cc-discover",
    "cc-amex",
    "cc-paypal",
    "cc-stripe",
    "bell-slash",
    "bell-slash-o",
    "trash",
    "copyright",
    "at",
    "eyedropper",
    "paint-brush",
    "birthday-cake",
    "area-chart",
    "pie-chart",
    "line-chart",
    "lastfm",
    "lastfm-square",
    "toggle-off",
    "toggle-on",
    "bicycle",
    "bus",
    "ioxhost",
    "angellist",
    "cc",
    "ils",
    "meanpath",
    "buysellads",
    "connectdevelop",
    "dashcube",
    "forumbee",
    "leanpub",
    "sellsy",
    "shirtsinbulk",
    "simplybuilt",
    "skyatlas",
    "cart-plus",
    "cart-arrow-down",
    "diamond",
    "ship",
    "user-secret",
    "motorcycle",
    "street-view",
    "heartbeat",
    "venus",
    "mars",
    "mercury",
    "transgender",
    "transgender-alt",
    "venus-double",
    "mars-double",
    "venus-mars",
    "mars-stroke",
    "mars-stroke-v",
    "mars-stroke-h",
    "neuter",
    "genderless",
    "facebook-official",
    "pinterest-p",
    "whatsapp",
    "server",
    "user-plus",
    "user-times",
    "bed",
    "viacoin",
    "train",
    "subway",
    "medium",
    "y-combinator",
    "optin-monster",
    "opencart",
    "expeditedssl",
    "battery-full",
    "battery-three-quarters",
    "battery-half",
    "battery-quarter",
    "battery-empty",
    "mouse-pointer",
    "i-cursor",
    "object-group",
    "object-ungroup",
    "sticky-note",
    "sticky-note-o",
    "cc-jcb",
    "cc-diners-club",
    "clone",
    "balance-scale",
    "hourglass-o",
    "hourglass-start",
    "hourglass-half",
    "hourglass-end",
    "hourglass",
    "hand-rock-o",
    "hand-paper-o",
    "hand-scissors-o",
    "hand-lizard-o",
    "hand-spock-o",
    "hand-pointer-o",
    "hand-peace-o",
    "trademark",
    "registered",
    "creative-commons",
    "gg",
    "gg-circle",
    "tripadvisor",
    "odnoklassniki",
    "odnoklassniki-square",
    "get-pocket",
    "wikipedia-w",
    "safari",
    "chrome",
    "firefox",
    "opera",
    "internet-explorer",
    "television",
    "contao",
    "500px",
    "amazon",
    "calendar-plus-o",
    "calendar-minus-o",
    "calendar-times-o",
    "calendar-check-o",
    "industry",
    "map-pin",
    "map-signs",
    "map-o",
    "map",
    "commenting",
    "commenting-o",
    "houzz",
    "vimeo",
    "black-tie",
    "fonticons",
    "reddit-alien",
    "edge",
    "credit-card-alt",
    "codiepie",
    "modx",
    "fort-awesome",
    "usb",
    "product-hunt",
    "mixcloud",
    "scribd",
    "pause-circle",
    "pause-circle-o",
    "stop-circle",
    "stop-circle-o",
    "shopping-bag",
    "shopping-basket",
    "hashtag",
    "bluetooth",
    "bluetooth-b",
    "percent",
    "gitlab",
    "wpbeginner",
    "wpforms",
    "envira",
    "universal-access",
    "wheelchair-alt",
    "question-circle-o",
    "blind",
    "audio-description",
    "volume-control-phone",
    "braille",
    "assistive-listening-systems",
    "american-sign-language-interpreting",
    "deaf",
    "glide",
    "glide-g",
    "sign-language",
    "low-vision",
    "viadeo",
    "viadeo-square",
    "snapchat",
    "snapchat-ghost",
    "snapchat-square",
    "pied-piper",
    "first-order",
    "yoast",
    "themeisle",
    "google-plus-official",
    "font-awesome",
    "handshake-o",
    "envelope-open",
    "envelope-open-o",
    "linode",
    "address-book",
    "address-book-o",
    "address-card",
    "address-card-o",
    "user-circle",
    "user-circle-o",
    "user-o",
    "id-badge",
    "id-card",
    "id-card-o",
    "quora",
    "free-code-camp",
    "telegram",
    "thermometer-full",
    "thermometer-three-quarters",
    "thermometer-half",
    "thermometer-quarter",
    "thermometer-empty",
    "shower",
    "bath",
    "podcast",
    "window-maximize",
    "window-minimize",
    "window-restore",
    "window-close",
    "window-close-o",
    "bandcamp",
    "grav",
    "etsy",
    "imdb",
    "ravelry",
    "eercast",
    "microchip",
    "snowflake-o",
    "superpowers",
    "wpexplorer",
    "meetup"
];


/*
 webChef v1
 Developed and maintained by [Anam Ahmed](http://anam.co)
 License: MIT
*/

(function(window) {
    'use strict';

    var webChef = Object.create(null);

    webChef.cook = function(text, vals) {
        var output = text,
            exprs = text.match(/<%\s?\w+\s?%>/ig);

        exprs.forEach(function(el) {
            output = output.replace(el, vals[el.match(/<%\s?(\w+)\s?%>/i)[1]] || "");
        });

        return output;
    };

    webChef.makeRecipe = function(text) {
        return function(data) {
            return webChef.cook(text, data);
        };
    };

    //expose webChef to global object
    window.webChef = webChef;
}(window));
/*!
 * Bootstrap v3.3.4 (http://getbootstrap.com)
 * Copyright 2011-2015 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 */

/*!
 * Generated using the Bootstrap Customizer (http://getbootstrap.com/customize/?id=e8a05d70918b35536043)
 * Config saved to config.json and https://gist.github.com/e8a05d70918b35536043
 */
if (typeof jQuery === 'undefined') {
    throw new Error('Bootstrap\'s JavaScript requires jQuery')
} +

function($) {
    'use strict';
    var version = $.fn.jquery.split(' ')[0].split('.')
    if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {
        throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher')
    }
}(jQuery);

/* ========================================================================
 * Bootstrap: modal.js v3.3.2
 * http://getbootstrap.com/javascript/#modals
 * ========================================================================
 * Copyright 2011-2015 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */


+

function($) {
    'use strict';

    // MODAL CLASS DEFINITION
    // ======================

    var Modal = function(element, options) {
        this.options = options
        this.$body = $(document.body)
        this.$element = $(element)
        this.$dialog = this.$element.find('.modal-dialog')
        this.$backdrop = null
        this.isShown = null
        this.originalBodyPad = null
        this.scrollbarWidth = 0
        this.ignoreBackdropClick = false

        if (this.options.remote) {
            this.$element
                .find('.modal-content')
                .load(this.options.remote, $.proxy(function() {
                    this.$element.trigger('loaded.bs.modal')
                }, this))
        }
    }

    Modal.VERSION = '3.3.2'

    Modal.TRANSITION_DURATION = 300
    Modal.BACKDROP_TRANSITION_DURATION = 150

    Modal.DEFAULTS = {
        backdrop: true,
        keyboard: true,
        show: true
    }

    Modal.prototype.toggle = function(_relatedTarget) {
        return this.isShown ? this.hide() : this.show(_relatedTarget)
    }

    Modal.prototype.show = function(_relatedTarget) {
        var that = this
        var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })

        this.$element.trigger(e)

        if (this.isShown || e.isDefaultPrevented()) return

        this.isShown = true

        this.checkScrollbar()
        this.setScrollbar()
        this.$body.addClass('modal-open')

        this.escape()
        this.resize()

        this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))

        this.$dialog.on('mousedown.dismiss.bs.modal', function() {
            that.$element.one('mouseup.dismiss.bs.modal', function(e) {
                if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
            })
        })

        this.backdrop(function() {
            var transition = $.support.transition && that.$element.hasClass('fade')

            if (!that.$element.parent().length) {
                that.$element.appendTo(that.$body) // don't move modals dom position
            }

            that.$element
                .show()
                .scrollTop(0)

            that.adjustDialog()

            if (transition) {
                that.$element[0].offsetWidth // force reflow
            }

            that.$element
                .addClass('in')
                .attr('aria-hidden', false)

            that.enforceFocus()

            var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })

            transition ?
                that.$dialog // wait for modal to slide in
                .one('bsTransitionEnd', function() {
                    that.$element.trigger('focus').trigger(e)
                })
                .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
                that.$element.trigger('focus').trigger(e)
        })
    }

    Modal.prototype.hide = function(e) {
        if (e) e.preventDefault()

        e = $.Event('hide.bs.modal')

        this.$element.trigger(e)

        if (!this.isShown || e.isDefaultPrevented()) return

        this.isShown = false

        this.escape()
        this.resize()

        $(document).off('focusin.bs.modal')

        this.$element
            .removeClass('in')
            .attr('aria-hidden', true)
            .off('click.dismiss.bs.modal')
            .off('mouseup.dismiss.bs.modal')

        this.$dialog.off('mousedown.dismiss.bs.modal')

        $.support.transition && this.$element.hasClass('fade') ?
            this.$element
            .one('bsTransitionEnd', $.proxy(this.hideModal, this))
            .emulateTransitionEnd(Modal.TRANSITION_DURATION) :
            this.hideModal()
    }

    Modal.prototype.enforceFocus = function() {
        $(document)
            .off('focusin.bs.modal') // guard against infinite focus loop
            .on('focusin.bs.modal', $.proxy(function(e) {
                if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
                    this.$element.trigger('focus')
                }
            }, this))
    }

    Modal.prototype.escape = function() {
        if (this.isShown && this.options.keyboard) {
            this.$element.on('keydown.dismiss.bs.modal', $.proxy(function(e) {
                e.which == 27 && this.hide()
            }, this))
        } else if (!this.isShown) {
            this.$element.off('keydown.dismiss.bs.modal')
        }
    }

    Modal.prototype.resize = function() {
        if (this.isShown) {
            $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this))
        } else {
            $(window).off('resize.bs.modal')
        }
    }

    Modal.prototype.hideModal = function() {
        var that = this
        this.$element.hide()
        this.backdrop(function() {
            that.$body.removeClass('modal-open')
            that.resetAdjustments()
            that.resetScrollbar()
            that.$element.trigger('hidden.bs.modal')
        })
    }

    Modal.prototype.removeBackdrop = function() {
        this.$backdrop && this.$backdrop.remove()
        this.$backdrop = null
    }

    Modal.prototype.backdrop = function(callback) {
        var that = this
        var animate = this.$element.hasClass('fade') ? 'fade' : ''

        if (this.isShown && this.options.backdrop) {
            var doAnimate = $.support.transition && animate

            this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
                .appendTo(this.$body)

            this.$element.on('click.dismiss.bs.modal', $.proxy(function(e) {
                if (this.ignoreBackdropClick) {
                    this.ignoreBackdropClick = false
                    return
                }
                if (e.target !== e.currentTarget) return
                this.options.backdrop == 'static' ?
                    this.$element[0].focus() :
                    this.hide()
            }, this))

            if (doAnimate) this.$backdrop[0].offsetWidth // force reflow

            this.$backdrop.addClass('in')

            if (!callback) return

            doAnimate ?
                this.$backdrop
                .one('bsTransitionEnd', callback)
                .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
                callback()

        } else if (!this.isShown && this.$backdrop) {
            this.$backdrop.removeClass('in')

            var callbackRemove = function() {
                that.removeBackdrop()
                callback && callback()
            }
            $.support.transition && this.$element.hasClass('fade') ?
                this.$backdrop
                .one('bsTransitionEnd', callbackRemove)
                .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) :
                callbackRemove()

        } else if (callback) {
            callback()
        }
    }

    // these following methods are used to handle overflowing modals

    Modal.prototype.handleUpdate = function() {
        this.adjustDialog()
    }

    Modal.prototype.adjustDialog = function() {
        var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight

        this.$element.css({
            paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
            paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
        })
    }

    Modal.prototype.resetAdjustments = function() {
        this.$element.css({
            paddingLeft: '',
            paddingRight: ''
        })
    }

    Modal.prototype.checkScrollbar = function() {
        var fullWindowWidth = window.innerWidth
        if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8
            var documentElementRect = document.documentElement.getBoundingClientRect()
            fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
        }
        this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth
        this.scrollbarWidth = this.measureScrollbar()
    }

    Modal.prototype.setScrollbar = function() {
        var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
        this.originalBodyPad = document.body.style.paddingRight || ''
        if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
    }

    Modal.prototype.resetScrollbar = function() {
        this.$body.css('padding-right', this.originalBodyPad)
    }

    Modal.prototype.measureScrollbar = function() { // thx walsh
        var scrollDiv = document.createElement('div')
        scrollDiv.className = 'modal-scrollbar-measure'
        this.$body.append(scrollDiv)
        var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
        this.$body[0].removeChild(scrollDiv)
        return scrollbarWidth
    }


    // MODAL PLUGIN DEFINITION
    // =======================

    function Plugin(option, _relatedTarget) {
        return this.each(function() {
            var $this = $(this)
            var data = $this.data('bs.modal')
            var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)

            if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
            if (typeof option == 'string') data[option](_relatedTarget)
            else if (options.show) data.show(_relatedTarget)
        })
    }

    var old = $.fn.modal

    $.fn.modal = Plugin
    $.fn.modal.Constructor = Modal


    // MODAL NO CONFLICT
    // =================

    $.fn.modal.noConflict = function() {
        $.fn.modal = old
        return this
    }


    // MODAL DATA-API
    // ==============

    $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function(e) {
        var $this = $(this)
        var href = $this.attr('href')
        var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
        var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())

        if ($this.is('a')) e.preventDefault()

        $target.one('show.bs.modal', function(showEvent) {
            if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
            $target.one('hidden.bs.modal', function() {
                $this.is(':visible') && $this.trigger('focus')
            })
        })
        Plugin.call($target, option, this)
    })

}(jQuery);

(function($, icons, webChef) {
    var ACTIVE_INPUT;

    var iconLiTemplate =
        '<li class="<%active%>">' +
        '<span class="fa fa-<%icon%>"></span>' +
        '<p><%icon%> </p>' +
        '</li>';

    var iconModalTemplate =
        '<div class="modal fade" id="tx-icon-list-modal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="Icon List" aria-hidden="true">' +
        '<div class="modal-dialog">' +
        '<div class="modal-content">' +
        '<div class="modal-header">' +
        '<input type="text" id="tx-icon-search" class="form-control" placeholder="搜索图标">' +
        '</div>' +

        '<div class="modal-body clearfix">' +
        '<div class="form-group">' +
        '<ul class="tx-icons-list clearfix"></ul>' +
        '</div>' +
        '</div>' +

        '<div class="modal-footer">' +
        '<button type="button" class="btn btn-danger pull-left" data-dismiss="modal">关闭</button>' +
        '<button type="button" class="btn btn-success icon-insert-button pull-right">确定选择</button>' +
        '</div>' +
        '</div>' +
        '</div>' +
        '</div>';

    var getSuggestedIcons = function(query) {
        return $.grep(icons, function(icon) {
            return icon.indexOf(query) !== -1;
        });
    };

    var generateIconsList = function(icons) {
        var iconvalue = ACTIVE_INPUT ? ACTIVE_INPUT.val() : "";

        var list = $.map(icons, function(icon) {
            var active = iconvalue ? (icon === iconvalue.split(" ")[1].replace("fa-", "")) : false;

            return webChef.cook(iconLiTemplate, { 'icon': icon, size: "", active: active ? 'active' : "" });
        });

        return list.join("");
    };

    var generateIconsDOM = function(icons) {
        var list = generateIconsList(icons);
        $(".tx-icons-list").html(list);
    };

    var getSelectedIcon = function() {
        var iconClass = $(".tx-icons-list li.active span").attr('class');
        return iconClass ? iconClass : false;
    };

    $(document).on("click", ".icon-insert-button", function() {
        var icon = getSelectedIcon();
        if (!icon) {
            alert("please select an icon to select");
            return;
        }

        ACTIVE_INPUT.val(icon);
        ACTIVE_INPUT.trigger("icon:inserted");
        $("#tx-icon-list-modal").modal('hide');
    });

    $(document).on("keyup change", "#tx-icon-search", function() {
        var query = $(this).val();
        var suggestedIcons = getSuggestedIcons(query);
        generateIconsDOM(suggestedIcons);
    });

    $(document).on("click", ".tx-icons-list li", function() {
        $(".tx-icons-list li").removeClass("active");
        $(this).addClass("active");
    });



    var iconSelector = function(options) {
        $(this).on("click", function() {
            ACTIVE_INPUT = $(options.input);
            $("#tx-icon-list-modal").modal('show');
            generateIconsDOM(icons);
        });
    };

    //onload
    $(function() {
        $("body").append(iconModalTemplate);
        generateIconsDOM(icons);
    });

    $.fn.iconSelector = iconSelector;

}(jQuery, tx_font_awesome_icons, webChef));